<template>
  <div id="accomplishbox">
    <div style="margin-bottom: 10px">
      <el-input v-model="input" placeholder="请输入订单号"></el-input>
      <el-button type="primary" style="margin-left: 10px" @click="search">搜索</el-button>
    </div>
    <el-table :data="tableData" border style="width: 100%"   :header-cell-style="{textAlign: 'center'}" :cell-style="{ textAlign: 'center'}">
      <el-table-column fixed prop="_id" label="理赔单号"> </el-table-column>
      <el-table-column prop="applyDate" label="申请时间"> </el-table-column>
      <el-table-column prop="troubleDate" label="事故时间"> </el-table-column>
      <el-table-column prop="state" label="理赔状态">
        <template slot-scope="scope">
          <span v-show="scope.row.state == 1">进行中</span>
        </template>
      </el-table-column>
      <el-table-column prop="claimsImages" label="理赔图片">
        <template slot-scope="scope">
          <img
            :src="'http://localhost:3000/images/' + scope.row.claimsImages"
            alt=""
            width="70px"
          />
        </template>
      </el-table-column>
      <el-table-column prop="order" label="所属订单"> </el-table-column>
      <el-table-column fixed="right" label="操作">
        <template slot-scope="scope" >
          <!-- <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button> -->
          <el-button type="success" size="small" @click="okClaimsApply({_id:scope.row._id,pageSize,currentPage})" :style="{fontSize:'14px'}">yes</el-button>
          <el-button type="danger" size="small" @click="noClaimsApply({_id:scope.row._id,pageSize,currentPage})" :style="{fontSize:'14px'}">no</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="block">
      <span class="demonstration">完整功能</span>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[3, 6, 9]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="totals"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { createNamespacedHelpers } from "vuex";
let { mapState, mapActions } = createNamespacedHelpers("accomplish");
export default {
  data() {
    return {
      input: "",
      currentPage: 1,
      pageSize: 3,
    };
  },
  mounted() {
    this.getClaimApply({ pageSize: 3 });
  },
  computed: {
    ...mapState(["tableData", "totals"]),
  },
  methods: {
    ...mapActions(["getClaimApply", "okClaimsApply", "noClaimsApply"]),
    //查看tr
    // handleClick(row) {
    //   console.log(row);
    // },
    //分页功能开始
    handleSizeChange(val) {
      this.pageSize = val;
      // this.currentPage = 1;
      this.getClaimApply({ pageSize: val, currentPage: this.currentPage });
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getClaimApply({ pageSize: this.pageSize, currentPage: val });
    },
    //分页功能结束
    //搜索
    search() {
      this.getClaimApply({
        pageSize: this.pageSize,
        currentPage: this.currentPage,
        _id: this.input,
      });
    },
  },
};
</script>

<style scoped>
.el-input {
  width: 200px;
}
</style>